//
// Created by liushuai on 2021/2/25.
//

#include "findContentChildren.h"

int findContentChildren(vector<int> &g, vector<int> &s) {
<<<<<<< HEAD:cxx/algorithm/src/findContentChildren.cc
    std::sort(g.begin(), g.end());
    std::sort(s.begin(), s.end());
    int min_size = g.size() < s.size() ? g.size() : s.size();
    int start1 = 0, start2 = 0, res = 0;
    while (start1 < g.size() && start2 < s.size()) {
        int current = g[start1];
        while (start2<s.size() && s[start2]<current)
            start2++;
        if(start2==s.size()){
            break;
        }
        if(start2<s.size()){
            ++res;
            ++start2;
            ++start1;
        }
    }
    return res;
=======
  std::sort(g.begin(), g.end());
  std::sort(s.begin(), s.end());
  int min_size = g.size() < s.size() ? g.size() : s.size();
  int start1 = 0, start2 = 0, res = 0;
  while (start1 < g.size() && start2 < s.size()) {
    int current = g[start1];
    while (start2 < s.size() && s[start2] < current) start2++;
    if (start2 == s.size()) {
      break;
    }
    if (start2 < s.size()) {
      ++res;
      ++start2;
      ++start1;
    }
  }
  return res;
>>>>>>> dev:cxx/algorithm/common/src/findContentChildren.cc
}